﻿using System;
using System.Collections.Generic;

using System.Linq;
using System.Text;
using System.Reflection;

namespace Flame.Dlr
{
    public class ScopeParameters 
    {
        public List<Variable> Variables { get; set; }
        public List<AssemblyWrapper> Assemblies { get; set; }
        public List<Script> Scripts { get; set; }

        public void Apply(IExecutable exec)
        {
            foreach (var v in Variables)
                exec.AddVariable(v);

            AssemblyHelper.Apply(Assemblies, exec);

            foreach (var s in Scripts)
            {
                if (s.Language == exec.GetType())
                    exec.Execute(s.Code);
            }
        }

        public ScopeParameters()
        {
            Variables = new List<Variable>();
            Assemblies = new List<AssemblyWrapper>();
            Scripts = new List<Script>();
        }

        public void AddAppDomainAssemblies()
        {
            Assemblies = Assemblies.Concat<AssemblyWrapper>(AssemblyHelper.CurrentAppDomainAssemblies).ToList();
        }

        public void AddFlameAssemblies()
        {
            Assemblies = Assemblies.Concat<AssemblyWrapper>(AssemblyHelper.CurrentFlameAssemblies).ToList();
        }
    }
}
